<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@page session="true"%>

<!DOCTYPE html>
<html>
<head>
    <jsp:include page="./../util/configurationPage.jsp"/>
</head>
<title>Dodaj użytkownika</title>
<style>


td>span{
    display:block;
}
body table{
    width:400px;
}
tr td:first-child {
    width: 30%;
    text-align: right;
    color: blue;
}
</style>
</head>
<body class="bg-body">
    <jsp:include page="./../util/navbar/navbarMain.jsp"/>
    <br>
    <div class="container">
            <div class="row">
                <div class="panel panel-primary col-lg-offset-3 col-lg-6">
                    <div class="panel-heading">
                        <h2 class="panel-title text-center">Dodawanie nowego użytkownika</h2>
                    </div>
                    <div class="panel-body">
                        <form:form role="form" cssClass="form-horizontal" commandName='user' action="saveUser" method='POST'>
                        <form:errors path="*" cssClass="alert alert-danger text-center" element="div" />

                            <div class="form-group">
                                <form:label cssClass="control-label col-sm-4" path="login">Login:</form:label>
                                <div class="col-sm-8">
                                    <form:input cssClass="form-control" path="login" />
                                </div>
                            </div>
                            <hr>
                            <div class="form-group">
                                <form:label cssClass="control-label col-sm-4" path="password">Hasło:</form:label>
                                <div class="col-sm-8">
                                    <form:password cssClass="form-control" path="password" />
                                </div>
                            </div>
                            <div class="form-group">
                                <form:label cssClass="control-label col-sm-4" path="rePassword">Powtórz hasło:</form:label>
                                <div class="col-sm-8">
                                    <form:password cssClass="form-control" path="rePassword" />
                                </div>
                            </div>
                            <hr>
                            <div class="form-group">
                                <form:label cssClass="control-label col-sm-4" path="departments">Dział:</form:label>
                                <div class="col-sm-8">
                                    <form:select multiple="false" cssClass="form-control" items="${departmentsMap}" path="departments"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <form:label cssClass="control-label col-sm-4" path="roles">Role:</form:label>
                                <div class="col-sm-8 checkbox">
                                    <form:checkboxes element="div" items="${rolesMap}" path="roles"/>
                                </div>
                            </div>

                            <hr>
                            <input class="btn btn-success pull-right" name="submit" type="submit" value="Zapisz"/>

                            <input type="hidden" name="${_csrf.parameterName}"	value="${_csrf.token}"/>
                        </form:form>
                    </div>
                </div>
	        </div>
	</div>
</body>
</html>